package com.nzx.common.session;

/**
 * 功能描述：登录用户上下文信息
 *
 * @author nzx
 * @date 2021/11/11 13:48
 */
public class SessionContext {

    //存储登录用户信息
    private static ThreadLocal<SessionUser> USER_HOLDER = new ThreadLocal<>();

    public static void setSessionUser(SessionUser user) {
        USER_HOLDER.set(user);
    }

    public static SessionUser getSessionUser() {
        return USER_HOLDER.get();
    }

    public static void clearSessionContext() {
        USER_HOLDER.remove();
    }
}
